package org.tale.mscp.activemq.Consumers;

import org.springframework.jms.annotation.JmsListener;

import javax.jms.JMSException;
import javax.jms.Session;
import javax.jms.TextMessage;


public class Consumers {

    @JmsListener(destination = "testQueue", containerFactory = "jmsQueueListener")
    public void receiveQueue(final TextMessage text, Session session) throws JMSException {

        try {

            if (text.getText().indexOf("1") > -1) {
                text.acknowledge();
                System.out.println(text.getText() + "消息已经消费了");
            } else {
                text.acknowledge();
                System.out.println(text.getText() + "消息未消费了");
//                session.recover();
            }
//            System.out.println(text.getText()+"消息已经消费了");
//            text.acknowledge();
        } catch (Exception e) {
            e.printStackTrace();
            session.recover();
        }

    }

}
